//
//  ProductPackageTableViewCell.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/4/29.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "ProductPackageTableViewCell.h"

@implementation ProductPackageTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addMySubview];
    }
    return self;
}

// 布局
- (void)addMySubview
{
    self.productPackageImageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 200 * kAdjustParamater)];
    self.productPackageImageV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    [self.contentView addSubview:_productPackageImageV];

    // 灰色条
    self.grayLineOnBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, self.productPackageImageV.bottom, kScreenWidth, 10 * kAdjustParamater)];
    self.grayLineOnBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
    [self.contentView addSubview:_grayLineOnBottom];
    
}

- (void)setModel:(ProductPackageModel *)model
{
   NSString *imageUrl = [model.unlock_img_url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    [self.productPackageImageV sd_setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:@""] options:SDWebImageRetryFailed completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        self.productPackageImageV.frame = CGRectMake(0, 0, kScreenWidth, image.size.height / 2);
    //    NSLog(@"宽度：%f 高度：%f", image.size.width, image.size.height);
        // 更改灰色条的高度
        self.grayLineOnBottom.frame = CGRectMake(0, self.productPackageImageV.bottom, kScreenWidth, 10 * kAdjustParamater);
    }];
   
}












@end
